﻿using Microsoft.Extensions.DependencyInjection;
using Nxg.Blog.Core.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Nxg.Blog.Web.Features
{
    public class CommandInvokerFactory : ICommandInvokerFactory
    {
        private readonly IServiceProvider _serviceProvider;

        public CommandInvokerFactory(IServiceProvider provider)
        {
            _serviceProvider = provider;
        }
        public TOut Handle<TIn, TOut>(TIn input)
        {
            var loadtr = _serviceProvider.GetService<ICommandInvoker<TIn, TOut>>();
            return loadtr.Execute(input);
        }
    }
}
